package com.zr.model;
// Generated 2016-6-19 19:35:13 by Hibernate Tools 3.2.2.GA

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * TRole generated by hbm2java
 */
@Entity
@Table(name = "t_role", catalog = "ld_sys")
public class TRole implements java.io.Serializable {

	private Integer rid;
	private String rname;
	private Set<TUser> TUsers = new HashSet<TUser>();
	private Set<TFunc> TFuncs = new HashSet<TFunc>();

	public TRole() {
	}

	public TRole(String rname, Set<TUser> TUsers, Set<TFunc> TFuncs) {
		this.rname = rname;
		this.TUsers = TUsers;
		this.TFuncs = TFuncs;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)

	@Column(name = "rid", unique = true, nullable = false)
	public Integer getRid() {
		return this.rid;
	}

	public void setRid(Integer rid) {
		this.rid = rid;
	}

	@Column(name = "rname")
	public String getRname() {
		return this.rname;
	}

	public void setRname(String rname) {
		this.rname = rname;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "TRole")
	public Set<TUser> getTUsers() {
		return this.TUsers;
	}

	public void setTUsers(Set<TUser> TUsers) {
		this.TUsers = TUsers;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinTable(name = "r_f", catalog = "ld_sys", joinColumns = {
			@JoinColumn(name = "rid", nullable = false, updatable = false) }, inverseJoinColumns = {
					@JoinColumn(name = "fid", nullable = false, updatable = false) })
	public Set<TFunc> getTFuncs() {
		return this.TFuncs;
	}

	public void setTFuncs(Set<TFunc> TFuncs) {
		this.TFuncs = TFuncs;
	}

}
